import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;

public class fileHandler {
	
private String inputFilename;
private String outputFilename;
private String tContent;
private String outputString;

public fileHandler (String inputFilename , String outputFilename){
	this.inputFilename = inputFilename;
	this.outputFilename = outputFilename;
	this.tContent = this.readFromFile();
}
public String toString(){
	return this.tContent;
}

public String readFromFile (){
	
	
	String tContent = "";
	
	//Must wrap working with files with try/catch
	try{
		//Creating a file object
		File tFile = new File(this.inputFilename);
		//Init inputstream
		FileInputStream fstream = new FileInputStream(tFile);
		DataInputStream in = new DataInputStream(fstream);
		//Creating a buffered reader.
		BufferedReader br = new BufferedReader(new InputStreamReader(in));
		String strLine;
		
		//Read File Line By Line
		while ((strLine = br.readLine()) != null){
			
			tContent = tContent + strLine + "\n";//concatenating the line to content string
		}
		//Close the input stream
		in.close();
	}
	catch(Exception e)//Catch exception if any
	{
		System.err.println("Error: " + e.getMessage());
	}
	return tContent;
}

}
